package com.itheima.mapper;

import com.itheima.domain.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @param
 * @return
 */
public interface UserMapper {
    @Select("SELECT  *  FROM user")
    @Results({
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "username",property = "username"),
            @Result(column = "sex",property = "sex"),
            @Result(property = "ordersList" ,javaType = List.class,column = "id",
            many = @Many(select = "com.itheima.mapper.OrdersMapper.findById" ,fetchType = FetchType.LAZY))
    })
    List<User> findAll();
}
